/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PWS;

import java.math.BigInteger;

/**
 *
 * @author LBAOMELM
 */
public class Methods {

    public static int mod(int a, int b) {
        return (a % b + b) % b;
    }

    @Deprecated
    public static int charToNums(char c) {
        for (int i = 0; i < Constants.ALFABET.length(); i++) {
            if (Character.toString(c).equalsIgnoreCase(
                    Character.toString(Constants.ALFABET.charAt(i)))) {
                return i;
            }
        }
        return -1;
    }

    public static int charToNum(char c) {
        return ((int) Character.toLowerCase(c)) - 97;
    }

    public static String createKey(String s, String k) {
        String out = "";
        int x = 0;

        while (out.length() < s.length()) {
            if (x == k.length()) {
                x = 0;
            }
            out += k.charAt(x);
            x++;
        }
        return out;
    }

    public static String stringToHex(String str) {

        char[] chars = str.toCharArray();

        StringBuffer hex = new StringBuffer();
        for (int i = 0; i < chars.length; i++) {
            hex.append(Integer.toHexString((int) chars[i]));
        }

        return hex.toString();
    }

    public static String charToHex(char c) {
        StringBuffer hex = new StringBuffer();
        return (hex.append(Integer.toHexString((int) c))).toString();
    }

    public static String[] createKeys(String s) {
        String[] keys = new String[s.length()];

        for (int i = 0; i < s.length(); ++i) {
            char c = s.charAt(i);
            int j = (int) c;
            int a = (int) Math.pow(Math.E * 2, Math.sqrt(j * Math.PI / Math.E));

            keys[i] = Integer.toHexString(a);
        }
        return keys;
    }

    public static int hex2decimal(String s) {
        String digits = "0123456789ABCDEF";
        s = s.toUpperCase();
        int val = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            int d = digits.indexOf(c);
            val = 16 * val + d;
        }
        return val;
    }

    public static void makeBigger() {
        double E = Math.E;
        double x = 1;
        double i = Math.pow(Math.E, x + 3);
        double j = Math.log(Math.log10((2 * x - 1) / 3));
    }
}
